import 'package:bruno/bruno.dart';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';


import '../../AppConfig/Config.dart';
import '../../l10n/messages.dart';
import 'BankCardWithdrawal.dart';


class Withdrawal extends StatefulWidget {

  const Withdrawal({super.key});

  @override
  State<Withdrawal> createState() => _WithdrawalState();
}

class _WithdrawalState extends State<Withdrawal> {
  double distanceToBottom = 0.0;

  @override
  void initState() {
    super.initState();

  }
  List chooseTitle=["充值交易","运单交易"];
  List orderNum=["1111111111","222222222","333333333"];
  List<ItemEntity> dataList = [
  ItemEntity(
  key: "one_list_key",
  value: "0",
    name:"充值交易",
  ),
    ItemEntity(
      key: "one_list_key",
      value: "1",
      name:"运单交易",
    ),

  ];

  int isHidden =0;
  int isStarttime=1;
  int listType=0;
  String selectedValue = '充值交易';

  List<String> options = ['充值交易', '运单交易',];

  List chooseList=[];
  List chooseList2=[];
  @override
  Widget build(BuildContext context) {

    var messages = AppLocalizations.of(context)!;
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
        backgroundColor: MyColors.backgreyColor,
        appBar: AppBar(
          leading: IconButton(
            icon: Icon(Icons.arrow_back_ios, color: Colors.black),
            onPressed: () => Navigator.of(context).pop(),
          ),
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text(messages['提现'],style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
        ),
      body: Column(
        children: [

        Expanded(
        child: Column(
          children: [

          Container(
            child: Stack(
              children: [
                listType==0?
                Container(
                  margin: EdgeInsets.only(top: 48.h),
                  height: orderNum.length * 98.h,
                  child: ListView.builder(

                      itemCount: orderNum.length,
                      itemBuilder: (BuildContext context, int index) {
                        return Container(
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(10)),
                            color: Colors.white,
                          ),
                          margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                          padding: EdgeInsets.only(top:10.h,bottom: 10.h,),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              SizedBox(width: 4.w,),
                              GestureDetector(
                                onTap: (){
                                  setState(() {
                                    chooseList.contains(index)?
                                    chooseList.remove(index):chooseList.add(index);
                                    print(chooseList);
                                  });
                                },
                                child: chooseList.contains(index)?Icon(Icons.
                        check_circle,color: MyColors.themeColor,size: 22)
                            :Icon(Icons.panorama_fish_eye,color: MyColors.hintColor,size: 22,)),

                              SizedBox(width: 4.w,),
                              Column(

                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Row(
                                    children: [
                                      Text("苏州市"+" "+"吴中区",style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                                      SizedBox(width: 4.w,),
                                      Container(
                                        width: 30.w,
                                        height: 1.h,
                                        color: Colors.black,
                                      ),
                                      SizedBox(width: 4.w,),
                                      Text("苏州市"+" "+"吴中区",style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                                    ],
                                  ),
                                  SizedBox(height: 4.w,),
                                  Text("运单号:"+orderNum[index],style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                                  SizedBox(height: 4.w,),
                                  Text("交易日期:"+"2023-03-02 11:19:52",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                                ],
                              ),
                              Text("¥:"+"2000.00",style: TextStyle(color: MyColors.themeColor,fontSize: 18.sp,fontWeight: FontWeight.w600),),
                            ],

                          ),
                        );

                      }

                  ),
                )
                :Container(
                    height: orderNum.length*85,
                  margin: EdgeInsets.only(top: 48.h),
                    child: ListView.builder(

                    itemCount: orderNum.length,
                    itemBuilder: (BuildContext context, int index) {
                return Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(10)),
                    color: Colors.white,
                  ),
                  margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                  padding: EdgeInsets.only(top:10.h,bottom: 10.h,),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      SizedBox(width: 4.w,),
                      GestureDetector(
                          onTap: (){
                            setState(() {
                              chooseList2.contains(index)?
                              chooseList2.remove(index):chooseList2.add(index);
                              print(chooseList2);
                            });
                          },
                          child: chooseList2.contains(index)?Icon(Icons.
                          check_circle,color: MyColors.themeColor,size: 22)
                              :Icon(Icons.panorama_fish_eye,color: MyColors.hintColor,size: 22,)),

                      SizedBox(width: 4.w,),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text("充值金额",style: TextStyle(color: Colors.black),),
                          SizedBox(height: 4.h,),
                          Text("充值日期："+"2023-03-02 11:19:52",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                        ],
                      ),
                      SizedBox(width: 8.w,),
                      Text("¥:"+"2000.00",style: TextStyle(color: MyColors.themeColor,fontSize: 18.sp,fontWeight: FontWeight.w600),),

                    ],
                  ),
                );
                    }
                ),
                ),

                Positioned(child:
                Container(
                  height:isHidden==0? 46.h:406.h,
                  padding: EdgeInsets.only(top: 8.h,bottom: 8.h,left: 10.w,right: 10.w),
                  color: Colors.white,
                  child: Column(
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            SizedBox(),
                            Container(
                              width: 110.w,
                              height: 30.h,
                              child:  BrnSimpleSelection.radio(

                                menuName: "充值交易",
                                menuKey: "default",
                                themeData: BrnSelectionConfig(
                                  menuNormalTextStyle:BrnTextStyle(color: Colors.black,fontSize: 14.sp),
                                  menuSelectedTextStyle:BrnTextStyle(color: MyColors.themeColor,fontSize: 14.sp),
                                  itemSelectedTextStyle:BrnTextStyle(color: MyColors.themeColor,fontSize: 14.sp),
                                    itemNormalTextStyle:BrnTextStyle(color: Colors.black,fontSize: 14.sp),
                                ),
                                items:dataList,
                                onSimpleSelectionChanged: (
                                    List<ItemEntity> filterParams) {
                                  //BrnToast.show(filterParams.map((e) => e.value).toList().join(','), context);
                                  setState(() {
                                    filterParams.map((e) => e.value).toList().join(',')=="0"?
                                        listType=0:listType=1;
                                  });
                                },

                              ),
                            ),
                            Container(height:15.h ,width:2.w,color: MyColors.backgreyColor,),
                            GestureDetector(
                              child: Container(
                                width: 120.w,
                                height: 30.h,
                                child:   Row(
                                  children: [
                                    Text("     "+"时间筛选",style: TextStyle(color: isHidden==0? Colors.black:MyColors.themeColor,),),

                                    Icon(
                                      isHidden==0?
                                      Icons.keyboard_arrow_down
                                      :Icons.keyboard_arrow_up,
                                      size: 11,color: MyColors.authTipColor,),
                                  ],
                                ),
                              ),
                            onTap: (){
                              setState(() {
                                if(isHidden==0) {
                                  isHidden = 1;
                                }else{
                                  isHidden = 0;
                                }
                              });
                            },
                            ),
                            SizedBox(),
                          ],
                        ),

                        Container(
                          // padding: EdgeInsets.only(top: 8.h),
                          height: isHidden==0 ?0.h:360.h,
                          child: Column(

                            children: [
                              SizedBox(height: 8.h,),

                              Container(
                                height: 1.h,
                                color: MyColors.backgreyColor,
                              ),
                              BrnCalendarView.range(
                                minDate: DateTime.now(),
                                maxDate: DateTime(2050),
                                rangeDateChange: (rangeDate) {
                                  BrnToast.show(
                                      '开始时间： ${rangeDate.start} , 结束时间：${rangeDate.end}', context);
                                },
                              ),
                              Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: [
                                  TextButton(onPressed: (){
                                    setState(() {
                                      isHidden=0;
                                    });
                                  }, child:Text("取消",style: TextStyle(color: Colors.black,),) ),
                                  TextButton(onPressed: (){
                                    setState(() {
                                      isHidden=0;
                                    });
                                  }, child:Text("确定",style: TextStyle(color: MyColors.themeColor),) ),
                                ],
                              ),

                            ],
                          ),
                        ),



               ],
                  ) ,

                ),

                ),
              ],
            ),

          ),








            ],
        ),
        ),
          Container(
            padding: EdgeInsets.all(8.w),
            height: 100.h,
            color: Colors.white,
            child: Column(
              children: [
               Row(
                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                 children: [
                   Row(

                     children: [
                       GestureDetector(
                         child: Container(
                           width: 15.w,
                           height:15.h,
                           child:Icon(Icons.panorama_fish_eye,) ,
                         ),
                        onTap: (){

                        },
                       ),
                      SizedBox(width: 8.w,),
                       Text("全选",style: TextStyle(color: Colors.black),),
                     ],
                   ),

                   Text("已选择"+(chooseList.length+chooseList2.length).toString()+"笔交易",style: TextStyle(color: MyColors.textColor)),
                 ],
               ),
                SizedBox(height: 8.h,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text("提现金额¥"+"40.00",style: TextStyle(color: MyColors.themeColor),),
                        Text("单笔提现限额"+"10000"+"元",style: TextStyle(color: MyColors.hintColor),),
                      ],
                    ),
                    GestureDetector(
                      child:    Container(
                          width: 160.w,
                          height: 30.h,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(30)),
                            color: MyColors.themeColor,
                          ),

                          child: Center(
                            child: Text("下一步",style: TextStyle(color: Colors.white),),
                          )
                      ),
                      onTap: (){
                        Navigator.push(context,
                            MaterialPageRoute(builder: (context) {
                              return BankCardWithdrawal(
                              );
                            }));
                      },
                    ),


                  ],
                )
              ],
            ),
          ),
        ],
      ),
    );

  }
}
